To convert a chart picture to a BSB chart, libbsb was for a long time the only choice.
With the arrival of “imgkap”, there is an alternative with updated features.
Updated source code available here:https://github.com/nohal/imgkap
Latest download of imgkap here:https://github.com/nohal/imgkap/releases
Original version of imgkap here: www.dacust.com/inlandwaters/imgkap/
For both tiff2bsb (libbsb) and imgkap there must be a user supplied “header” file containing information and Geo-referencing of the chart picture. This file can be produced in different ways. From simple handcrafting, to a method described on the page “Conversion Using Linux”, which actually applies to windows as well in many parts.
To see a real header, just open a chart file (whatever.kap) in a text-editor.
The first part of the text in the beginning us user supplied, then comes a text part created by libbsb or imgkap an then the binary part.
Whatever method is used for conversion it is important to understand the header.
Here is a commented header file that describes the essential items in a basic version.
VER/2.0 [0] BSB/NA= [1] NU=[2],RA=[3],[4],DU=72 KNP/SC=[5],GD=[6],PR=[7] PP=[8],PI=UNKNOWN,SP=UNKNOWN,SK=[8a],TA=[8b] UN=[9],SD=[10],DX=000,DY=000[11] CED/SE=[12],RE=[13],ED=[14] OST/1 REF/1,[16] REF/2, REF/3, REF/4, PLY/1,[17] PLY/2, PLY/3, PLY/4, DTM/0.00,0.00 [18] CPH/0.0 [19]
0. The BSB version used. 2.0 will do for home brewed charts.
1. *Name of chart from the chart. Warning do not use commas ",".
2. *Chart number. Plan A on 23456 should be named 23456_A
3. Size of picture Pixel x coordinate
4. Size of picture Pixel y coordinate
5. *Scale of the chart from the chart.
6. *Geodetic datum, for example WGS84, from the chart. If the geodetic datum cannot
be determined, don't convert the chart. OpenCPN V4.0 will treat it as WGS84, but
this requires a carefull check of the final chart.. For a list of approved
Datums see the file georef.cpp in the source code. Charts released earlier than
1990 (?) and conforming to World Geodetic System should be WGS72, unless
stated otherwise. The difference between WGS 84 and WGS 72 is minor.
7. *Projection, almost always MERCATOR, a few charts are TRANSVERSE MERCATOR.
We should not bother with other projections, GNOMONIC small scale great circle
charts etc. High latitude "Lambert Conformal Conic Projection" should be skipped,
for now. OpenCPN only handles Mercator, Transverse Mercator and Polyconic Charts.
Do not leave this value blank and don't use "UNKNOWN".
8. *For Mercator charts this is the latitude where the scale is valid. If available
on the chart, use that value. If it is not available on the chart use the average
value of the latitude of the upper and lower edge, to the nearest 1/10 of a degree.
For Transverse Mercator charts use the average _longitude_ of the eastern and western edge.
8a. SK is the skew angle of charts that are not "North Up". For North Up the value is 0.0.
From OpenCPN 3.3.1117 skewed charts without this parameter set, are handled internally,
and showed correctly. This is only to handled commercially issued charts that are not
correctly coded.
8b.TA is he text angle, more or less always 90.0
9. Unit for soundings from the chart, mostly METERS
10. Datum for soundings from the chart, for ex MLWS, LAT
11. x and y resolution, meters per pixel. Not necessary for us to compute. OpenCPN handles this.
12. Chart edition date copied from the chart,inf in SW corner, except, there must be _no_ commas.
13. Our release edition.
14. Our release date.\\
16. Geo-referencing, standard case - simple 4 corner chart, use the 4 corners, starting
in the SW corner proceeding clockwise. Format: x pix,y pix, lat, long. Lat & long in
decimal degrees, to 8 decimals, where N lat and E long are positive. One reason to use
all 4 corners is to catch skewed and warped charts, and calculate SK (8a), also to
calculate a rotating angle for charts that are not properly aligned.
If the chart is distorted or warped, use many REF points to let OpenCPN compute the 3rd
order coefficients to correct the errors.
17. Standard case, just copy the lat & long from the REFs.
18. Corrections in seconds of arc to bring the chart to WGS84. This is generally stated
on the chart (if they exist), in a format where the corrections are in minutes of arc
for plotting a WGS84 position on the chart. This correction must be transformed to
seconds of arc and the signs reversed.(we are doing the reverse to the case stated
on the charts). These values are sometimes difficult to find on the chart. Think of
OpenCPNs grid as a fixed WGS84 grid. A WGS 84 charts printed grid should agree with
OpenCPN', grid. If not, the Chart needs to be moved. Use + for N and E. Use O's
measure tool to measure the offset in meters.1 sec of arc latitude is 31 m. The
longitude varies with the latitude and 1 sec is about 15 m in lat 60.
19. If a chart spans the 180th meridian => CPH/180.0, else => CPH/0.0. So CPH/
is 0.0 for most charts. Note that OpenCPN handles transiting the 180:th meridian
while a few other plotters don't.
IFM is not used as tif2bsb and imgkap calculates this value and ads it to the header on the final kap, together with other values such as RGB. Any manually entered values will be overwritten.
One great advantage with imgkap, compared to libbsb, is that generally the original format for the chart picture can be used directly.
To calibrate a chart can be as simple as composing the headerfile , a text file with the extension “.txt”. Often the Lat&Long of the SW and NE corners are printed on the charts.
Use, for example GIMP, to find the pixel coordinates for each corner.
For example, to the chart picture BA1121.jpg we write the header file BA1121.txt.
To create the chart file with the extension “.kap”, issue the command:
imgkap BA1121.jpg BA1121.txt BA1121.kap
If OpenCPN can't open your new chart file, check opencpn.log, for information.
Note that any changes to the text part of a kap file must be done with an editor that does not change hidden features, like end of line encoding. This is especially a problem for Windows users, where “notepad” cannot be used. Download Notepad++ instead, https://notepad-plus-plus.org . Generally any binary- or hex- editor should be OK. After you have changed the kap file you must run “bsbfix” from libbsb.
bsbfix path-to-my-kapfile